local yuchen = fk.CreateSkill{
    name = "wk_heg__yuchen"
}

Fk:loadTranslationTable{
    ["wk_heg__yuchen"] = "驭臣",
    [":wk_heg__yuchen"] = "其他角色的结束阶段，若其本回合未造成过伤害，你可交给其两张手牌，令其执行一个额外的出牌阶段，若如此做，此额外的阶段结束时，若其于此阶段未造成过伤害，你对其造成1点伤害。",

    ["@@wk_heg__yuchen-turn"] = "驭臣",
    ["#wk_heg__yuchen-give"] = "驭臣：你可交给其两张手牌，令其执行一个额外的出牌阶段",

    ["$wk_heg__yuchen1"] = "大展宏图，就在今日。",
    ["$wk_heg__yuchen2"] = "复我大魏，扬我国威。",
}

yuchen:addEffect(fk.EventPhaseStart,{
    anim_type = "support",
    can_trigger = function (self, event, target, player, data)
        if not (player:hasSkill(yuchen.name) and target ~= player and target.phase == Player.Finish and player:getHandcardNum() > 1) then return false end
        return #player.room.logic:getActualDamageEvents(1, function(e)
          return e.data.from == target
        end, Player.HistoryTurn) == 0
      end,
    on_cost = function (self, event, target, player, data)
        local cards = player.room:askToCards(player,{
            min_num = 2,
            max_num = 2,
            include_equip = false,
            skill_name = yuchen.name,
            prompt = "#wk_heg__yuchen-give",
            cancelable = true,
        })
        if #cards == 2 then
          event:setCostData(self,{cards = cards})
          return true
        end
      end,
    on_use = function (self, event, target, player, data)
        local room = player.room
        local cards = event:getCostData(self).cards
        room:obtainCard(target, cards, false, fk.ReasonGive)
        if not target.dead then
          room:setPlayerMark(target, "@@wk_heg__yuchen-turn", 1)
          target:gainAnExtraPhase(Player.Play)
        end
      end,
})

yuchen:addEffect(fk.EventPhaseEnd,{
    anim_type = "support",
    is_delay_effect = true,
    can_trigger = function (self, event, target, player, data)
        if not (target:getMark("@@wk_heg__yuchen-turn") > 0 and target.phase == Player.Play and player:usedSkillTimes(yuchen.name, Player.HistoryTurn) > 0 and player:isAlive()) then return false end
        return #player.room.logic:getActualDamageEvents(1, function(e)
          return e.data.from == target
        end, Player.HistoryPhase) == 0
      end,
    on_cost = Util.TrueFunc,
    on_use = function (self, event, target, player, data)
        local room = player.room
        room:damage{
          from = player,
          to = target,
          damage = 1,
          skillName = yuchen.name,
        }
      end,
})

return yuchen